import { _decorator, Component, Widget } from "cc";
import { GameConfig } from "../data/GameConfig";

const { ccclass, property } = _decorator;

@ccclass("MarginTop")
export class MarginTop extends Component {

    private _top: number = 0;
    protected onLoad(): void {
        this._top = this.getComponent(Widget)?.top;
    }
    protected start(): void {
        const widget = this.getComponent(Widget);
        if (widget?.isAlignTop) {
            widget.top = this._top + GameConfig.marginTop;
        }
    }
}